{% extends 'base.html' %} {% block title %}Edit Sushi{% endblock %} {% block content %} {# Doing a bit of shenanigan, and using the same form for create and edit #} {# `if` statements in Jinja are explained here: https://jinja.palletsprojects.com/en/2.11.x/templates/#tests #}

The chosen action for the page is: {{ action }}

The value of the action variable is defined in flask_app.py

{# If action is "edit" then show the edit form. Otherwise (the action is "create"), show the create form. The forms are largely the same; only the label and action URL are different. #} {% if action == "edit" %}

Edit Sushi

{# Use the method name, not the route name in url_for #} {% else %}

Create Sushi

{% endif %}

{% if action == "edit" %} {% else %} {% endif %}

{% if action == "edit" %} {# Only offer delete if the item already exists #}
{% endif %} {% endblock %}